<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
	<head>
		<title>个人信息</title>
		<%@include file="/WEB-INF/base.jspf"%>
		<style type="text/css">
			#span-i-myHeMai, #span-i-hemaiWanfa, .buyTD, .indexTD {
				cursor: pointer;
			}
			*{font-size: 14px;}
			/* li{height: 60px;line-height: 60px;border-top: 1px solid #f2f2f2;} */
			th,td{text-align: center;}
			tr{background: white;height: 30px;}
			table *{font-size: 14px;}
			.detailInfo-in {
				display: block;
			}
			.li-c-wanfaInfo {
			padding-left: 17px;
			word-break: break-all;
			}
			.div-c-buyContentDiv > .buy-inner {
				display:block;
				text-align: center;
			}
			.div-c-buyContentDiv > .buy-inner > input {
			margin-top:16px;
			margin-bottom:16px;
			color:black;}
			.div-c-buyContentDiv > .buy-inner > button {
			margin-top:0;}
			.div-c-buyContentDiv > .buy-inner > button + button {
			margin-left:16px;}
			tbody th, tbody td {
				white-space:nowrap;
				padding:10px 0;
			}
			#span-i-myHeMai {
				margin-left:10px;
				font-weight:bold;
			}
			.sub-ul-wanfa {
				display:none;
			}
			.sub-ul-wanfa-active {
				display:block;
			}
			.modal-footer {
				padding: 6px;
    			text-align: center;
			}
			.moneyText {
				color:red;
			}
			.modal-footer > button {
				width:80%;
			}
			.myHeMaiItem, .ul-c-detailOrder {
				border-radius: 10px;
				border-top:5px solid red;
			    border: 1px solid silver;
			    box-shadow: 2px 3px 1px silver;
			    padding: 10px;
			    margin-bottom: 20px;
			    text-align: left;		
			    position: relative;	
			}
			.myHeMaiItem > span {
				position: absolute;
				top:-10px;
				left:10px;
				background-color:white;
				font-weight:bold;
			}
			.myHeMaiItem li {
				margin-bottom:5px;
			}
			.myHeMaiItem button {
				margin-top:0;
				width:46%;
			}
			.myHeMaiItem #li-i-btnDetail {
				text-align: center;
				margin-bottom:0;
			}
			.myHeMaiItem li:first-child {
				
			}
			.modal { overflow: auto !important; }
			.cancelScroll {
				overflow: hidden!important;
			}
			.fixed {
				position: fixed;
			}
			.myHeMaiItem.active .sub-ul-wanfa {
				display:block;
			}
			.div-c-buyContentDiv .div-c-modalContent > .fakemodal-title {
				padding-left:0;
				text-align: center;
			}
		</style>
		<script type="text/javascript" src="/js/font_612184_suc1kkwgeaa1c3di.js"></script>
	</head>

	<body style="background: #F1F1F1 ;">
		<div class="bg-theme col-xs-12 col-sm-4 col-sm-offset-4" style="height: 50px;line-height:50px;position: fixed;margin-top: 0px;left: 0px;z-index: 100;display:flex;justify-content:space-between;align-items:center;padding-left:0;padding-right:0;">
			<span id="span-i-myHeMai">我的合买</span>
			<strong style="font-size: 20px;">合买中心</strong>
			<div id="span-i-hemaiWanfa" style="font-size:14px;font-weight:bold;margin-right:10px;display:flex;align-items:center;">合买玩法</div>
		</div>
		<div class="col-xs-12 col-sm-4 col-sm-offset-4" style="padding: 0px;">
			<div style="height: 50px;"></div>
			<div style="overflow-x: auto;-webkit-overflow-scrolling : touch;">
				<table class="table-bordered" style="width: 100%;">
					<c:if test="${myOrders.size()==0 }"><div style="text-align: center;line-height: 100px;">您还没有任何记录，请先去<a href="/gc.do" style="font-weight: bold;color: blue;">下注</a></div></c:if>
					<tr>
						<th style="display:none;"></th>
						<th>序号</th>
						<th>发起人</th>
						<th style="display:none;">总份数</th>
						<th style="display:none;">剩余</th>
						<th>每份金额</th>
						<th>状态</th>
						<th>操作</th>
						<th>详情</th>
						<th style="display:none;"></th>
						<th style="display:none;"></th>
						<th style="display:none;"></th>
						<th style="display:none;"></th>
						<th style="display:none;"></th>
						<th style="display:none;"></th>
					<th style="display:none;"></th>
					<th style="display:none;"></th>
					<th style="display:none;"></th>
					<th style="display:none;"></th>
					<th style="display:none;"></th>
					<th style="display:none;"></th>
					<th style="display:none;"></th>
					<th style="display:none;"></th>
					<th style="display:none;"></th>
					<th style="display:none;"></th>
					<th style="display:none;"></th>
					<th style="display:none;"></th>
					<th style="display:none;"></th>
					<th style="display:none;"></th>
					<th style="display:none;"></th>
					<th style="display:none;"></th>
					<th style="display:none;"></th>
					<th style="display:none;"></th>
					<th style="display:none;"></th>		
					<th style="display:none;"></th>
					<th style="display:none;"></th>
					<th style="display:none;"></th>
					<th style="display:none;"></th>
					<th style="display:none;"></th>
					<th style="display:none;"></th>
					<th style="display:none;"></th>
					<th style="display:none;"></th>
					<th style="display:none;"></th>
					<th style="display:none;"></th>
					<th style="display:none;"></th>
					<th style="display:none;"></th>
					<th style="display:none;"></th>
					<th style="display:none;"></th>
					<th style="display:none;"></th>
					<th style="display:none;"></th>
					<th style="display:none;"></th>
					<th style="display:none;"></th>
					<th style="display:none;"></th>
					<th style="display:none;"></th>	
					<th style="display:none;"></th>						
					</tr>
					<c:forEach items="${syfaqhm}" var="l" varStatus="i" >
						<tr class="tr-c-HeMaiItemTr">
							<td style="display:none;" class="td-c-hemai-userId">${l.userid}</td>
							<td>${i.index + 1}</td>
							<td class="user-td">${l.user }</td>
							<td style="display:none;" class="zongfenshuTD">${l.zcount }</td>
							<td style="display:none;" class="scountTD">${l.scount }</td>
							<td>${l.price}</td>
							<td class="status-TD">
								<c:if test="${l.ddstate=='0' }">失效</c:if>
								<c:if test="${l.ddstate=='1' }">认购中</c:if>
								<c:if test="${l.ddstate=='2' }">已满员</c:if>
							</td>
						<td class="buyTD"><span class="buyBtnSpan td-gendan-control" data-id="${l.id}" data-zcount="${l.zcount}" data-price="${l.price}">购买</span></td>
						<td class="indexTD td-gendan-control">详情</td>
						<td class="qihaoTD" style="display:none;">${l.qihao}</td>
						<td class="caizhongTD" style="display:none;">${l.cpname}</td>
						<td class="fanganjine" style="display:none;">${l.fajine}</td>
						<td class="kaijianghaoma-TD" style="display:none;">${l.checkNum}</td>
						<td class="zhongjiangjine-TD" style="display:none;">${l.zjjine}</td>
						<td class="orderNum-TD" style="display:none;">${l.orderNum}</td>
						<td class="shenglv-TD" style="display:none;">${l.shenglv}</td>
						<td class="wanfaTD" style="display:none;" data-value="1">${l.cplay1}:${l.str1}</td>
						<td class="wanfaTD" style="display:none;" data-value="2">${l.cplay2}:${l.str2}</td>
						<td class="wanfaTD" style="display:none;" data-value="3">${l.cplay3}:${l.str3}</td>
						<td class="wanfaTD" style="display:none;" data-value="4">${l.cplay4}:${l.str4}</td>
						<td class="wanfaTD" style="display:none;" data-value="5">${l.cplay5}:${l.str5}</td>
						<td class="wanfaTD" style="display:none;" data-value="6">${l.cplay6}:${l.str6}</td>
						<td class="wanfaTD" style="display:none;" data-value="7">${l.cplay7}:${l.str7}</td>
						<td class="wanfaTD" style="display:none;" data-value="8">${l.cplay8}:${l.str8}</td>
						<td class="wanfaTD" style="display:none;" data-value="9">${l.cplay9}:${l.str9}</td>
						<td class="wanfaTD" style="display:none;" data-value="10">${l.cplay10}:${l.str10}</td>
						<td class="wanfaTD" style="display:none;" data-value="11">${l.cplay11}:${l.str11}</td>
						<td class="wanfaTD" style="display:none;" data-value="12">${l.cplay12}:${l.str12}</td>
						<td class="wanfaTD" style="display:none;" data-value="13">${l.cplay13}:${l.str13}</td>
						<td class="wanfaTD" style="display:none;" data-value="14">${l.cplay14}:${l.str14}</td>
						<td class="wanfaTD" style="display:none;" data-value="15">${l.cplay15}:${l.str15}</td>
						<td class="wanfaTD" style="display:none;" data-value="16">${l.cplay16}:${l.str16}</td>
						<td class="wanfaTD" style="display:none;" data-value="17">${l.cplay17}:${l.str17}</td>
						<td class="wanfaTD" style="display:none;" data-value="18">${l.cplay18}:${l.str18}</td>
						<td class="wanfaTD" style="display:none;" data-value="19">${l.cplay19}:${l.str19}</td>
						<td class="wanfaTD" style="display:none;" data-value="20">${l.cplay20}:${l.str20}</td>
						<td class="wanfaTD" style="display:none;" data-value="21">${l.cplay21}:${l.str21}</td>
						<td class="wanfaTD" style="display:none;" data-value="22">${l.cplay22}:${l.str22}</td>
						<td class="wanfaTD" style="display:none;" data-value="23">${l.cplay23}:${l.str23}</td>
						<td class="wanfaTD" style="display:none;" data-value="24">${l.cplay24}:${l.str24}</td>
						<td class="wanfaTD" style="display:none;" data-value="25">${l.cplay25}:${l.str25}</td>
						<td class="wanfaTD" style="display:none;" data-value="26">${l.cplay26}:${l.str26}</td>
						<td class="wanfaTD" style="display:none;" data-value="27">${l.cplay27}:${l.str27}</td>
						<td class="wanfaTD" style="display:none;" data-value="28">${l.cplay28}:${l.str28}</td>
						<td class="wanfaTD" style="display:none;" data-value="29">${l.cplay29}:${l.str29}</td>
						<td class="wanfaTD" style="display:none;" data-value="30">${l.cplay30}:${l.str30}</td>
						<td class="wanfaTD" style="display:none;" data-value="31">${l.cplay31}:${l.str31}</td>
						<td class="wanfaTD" style="display:none;" data-value="32">${l.cplay32}:${l.str32}</td>
						<td class="wanfaTD" style="display:none;" data-value="33">${l.cplay33}:${l.str33}</td>
						<td class="wanfaTD" style="display:none;" data-value="34">${l.cplay34}:${l.str34}</td>
						<td class="wanfaTD" style="display:none;" data-value="35">${l.cplay35}:${l.str35}</td>
						<td class="wanfaTD" style="display:none;" data-value="36">${l.cplay36}:${l.str36}</td>
						<td class="wanfaTD" style="display:none;" data-value="37">${l.cplay37}:${l.str37}</td>
						<td class="wanfaTD" style="display:none;" data-value="38">${l.cplay38}:${l.str38}</td>
						<td class="wanfaTD" style="display:none;" data-value="39">${l.cplay39}:${l.str39}</td>
						<td class="wanfaTD" style="display:none;" data-value="40">${l.cplay40}:${l.str40}</td>							
						</tr>
					</c:forEach>
				</table>
			</div>
			<br>
			<br>
			<br>
		</div>
		<div class="col-xs-12 col-sm-4 col-sm-offset-4 text-center foot">
			<iframe src="f.jsp"></iframe>
		</div>
		<div class="modal-div-fakeModal div-c-buyContentDiv">
			<div class="div-c-modalContent">
				<h3 class="fakemodal-title">请输入购买份数:</h3>
				<div class="fakemodal-content">
					<input class="form-control" id="input-buyFenShu" placeholder="请输入有效的数字" type="text" />
				</div>
				<div class="fakemodal-btnsGroup">
					<button class="btn btn-success" id="btn-i-confirmBuyFenShu">确认购买</button>
					<button class="btn btn-default btn-class-closeFakeModal">返回</button>
				</div>
			</div>
		</div>			
	<!-- 按钮触发模态框 -->
	
<div class="modal-div-fakeModal" id="div-i-noticeGenDan">
	<div class="div-c-modalContent">
		<h3 class="fakemodal-title"></h3>
		<div class="fakemodal-content"></div>
		<div class="fakemodal-btnsGroup"><button class="btn btn-default btn-class-closeFakeModal">关闭</button></div>
	</div>
</div>	
	
<!-- 模态框（Modal） -->
<div class="modal fade" id="detail-modal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <h4 class="modal-title" id="" style="text-align: center;">★订单详情★</h4>
            </div>
            <div class="modal-body">
            	<ul class="ul-c-detailOrder">
            		<li></li>
            		<li></li>
            		<li></li>
            		<li></li>
            		<li></li>
            		<li></li>
            	</ul>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-primary" data-dismiss="modal">关闭</button>
            </div>
        </div><!-- /.modal-content -->
    </div><!-- /.modal-dialog -->
</div>
<!-- /.modal -->	
	<!-- 模态框（Modal） -->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog" style="margin: 2vh auto;">
        <div class="modal-content">
            <div class="modal-header">
                <h4 class="modal-title" id="myModalLabel" style="text-align: center;letter-spacing:3px;">★我的合买★</h4>
            </div>
            <div class="modal-body" id="div-i-myHeMaiBody" style="height:55vh;overflow: auto;">
				<div class="div-c-collapseItem">
					<div class="div-c-collapseTitle">
						<svg class="icon" aria-hidden="true">
						    <use xlink:href="#icon-right"></use>
						</svg><span>我发起的合买<span class='span-c-tiaoshu'></span>条</span>
					</div>
					<div class="div-c-collapseContentWrapper" id="div-i-MyFaQiHeMai">
					</div>
				</div>
				<div class="div-c-collapseItem">
					<div class="div-c-collapseTitle">
						<svg class="icon" aria-hidden="true">
						    <use xlink:href="#icon-right"></use>
						</svg><span>我参与的合买<span class='span-c-tiaoshu'></span>条</span>
					</div>
					<div class="div-c-collapseContentWrapper"  id="div-i-MyCanYuHeMai">
					</div>
				</div>	
			</div>
            <div class="modal-footer">
                <button type="button" class="btn btn-primary" data-dismiss="modal">关闭</button>
            </div>
        </div><!-- /.modal-content -->
    </div><!-- /.modal -->
</div>				
	</body>
	<script type="text/javascript">
	var MY_USER_ID = "${user.id}"
	if ($(".tr-c-HeMaiItemTr").length == 0) {
		showNoResultNoticeModal("#div-i-noticeGenDan", "提示", "目前还没有用户发起合买", "点击前往，立刻下注！", getXiaZhuUrl())
	}
 	  var CAI_ZHONG_OBJECT = {
			
	  }
	  var RESULT_STATE_OBJECT = {
			  "1": "待开奖",
			  "2": "未中奖",
			  "3": "已中奖",
	  }
	<c:forEach items="${lotters}" var="l">
		CAI_ZHONG_OBJECT["${l.cname}"] = "${l.name}"
	</c:forEach>	
	var HEMAI_OBJECT = {
	}
	var numString = "0123456789"
	var checkIsNumber = function(number) {
		if (!number) {
			return false
		}
		if (number[0] == "0") {
			return false
		}
		for (var i = 0; i < number.length; i++) {
			var letter = number[i]
			if (!numString.includes(letter)) {
				return false
			}
		}
		return true
	}
	var setDetailData = function(element, data) {
		var parentTr = element.closest("tr")
		var ul = document.querySelector("#detail-modal .ul-c-detailOrder")
		ul.innerHTML = ""
		var qihaoValue = parentTr.querySelector(".qihaoTD").innerHTML
		var userName = parentTr.querySelector(".user-td").innerHTML
		var wanfaName = parentTr.querySelector(".caizhongTD").innerHTML
		var fanganValue = parentTr.querySelector(".fanganjine").innerHTML
		ul.insertAdjacentHTML("beforeend", "<li style='font-weight:bold;'><i class='fa fa-star'></i> 彩种: " + CAI_ZHONG_OBJECT[wanfaName] + "</li>")
		ul.insertAdjacentHTML("beforeend", "<li style='font-weight:bold;'><i class='fa fa-star'></i> 方案金额 : <span style='font-weight:bold;color:red;'>" + fanganValue + " 元</span></li>")
		ul.insertAdjacentHTML("beforeend", "<li style='font-weight:bold;'><i class='fa fa-star'></i> 期号 : " + qihaoValue + "</li>")
		var zongjineValue = parentTr.querySelector(".zongfenshuTD").innerHTML
		var meifenjineValue = parentTr.querySelector(".scountTD").innerHTML
		ul.insertAdjacentHTML("beforeend", "<li style='font-weight:bold;'><i class='fa fa-star'></i> 总份数 : " + zongjineValue + "</li>")
		ul.insertAdjacentHTML("beforeend", "<li style='font-weight:bold;'><i class='fa fa-star'></i> 剩余份数 : " + meifenjineValue + "</li>")
		var status = element.closest("tr").querySelector(".status-TD").innerHTML.trim()
		if (data.data[0].price == null) {
			var shenglvValue = ""
			for (var i = 0; i < data.data.length; i++) {
				var item = data.data[i]
				if (item.user == userName) {
					shenglvValue = item.shenglv
					break
				}
			}
			ul.insertAdjacentHTML("beforeend", "<li style='font-weight:bold;'><i class='fa fa-star'></i> 胜率 : <span style='color:red;font-weight:bold;'>" + shenglvValue + "</span></li>")			
		} else {
			var allWanFa = parentTr.querySelectorAll(".wanfaTD")
			ul.insertAdjacentHTML("beforeend", "<li style='font-weight:bold;'><i class='fa fa-star'></i> 投注玩法 : " + "" + "</li>")
			for (var i = 0; i < allWanFa.length; i++) {
				var item = allWanFa[i]
				if (item.innerHTML.length > 1) {
					var newHTML = "<li class='li-c-wanfaInfo'>" + item.innerHTML + "</li>"
					ul.insertAdjacentHTML("beforeend", newHTML)
				}
			}			
		}
	}
   var bindAllDetailIndexEvent = function() {
	   var allIndexs = document.querySelectorAll(".indexTD")
	   for (var i = 0; i < allIndexs.length; i++) {
		   var item = allIndexs[i]
		   item.addEventListener(getEndClickEvent(), function(event) {
			   // 发个 ajax, 判断他有没有对这单下注
			   var orderNum = event.target.closest("tr").querySelector(".orderNum-TD").innerHTML
				var urlPath = "/checkhm.do"
				var newRequest = {
					url: urlPath,
					type: "post",
					data: {orderNum: orderNum},
					success: function(data) {
						var newData = JSON.parse(data)
					    setDetailData(event.target, newData)
					    document.body.classList.add("cancelScroll")
					    //document.querySelector(".div-c-detailInfo").classList.add("detailInfo-in")
					    $("#detail-modal").modal("show")
					},
					error: function(status) {
						showNormalNoticeModal("#div-i-noticeGenDan", "提示：", "网络异常，请稍后重试")
					}
				}
				ajax(newRequest)			   
		   })
	   }
   }
	var upDateShengYuTd = function(array) {
		var tds = document.querySelectorAll(".scountTD")
		for (var i = 0; i < tds.length; i++) {
			var item = tds[i]
			item.innerHTML = array[i]
		}
	}
		
	var allBuyBtns = document.querySelectorAll(".buyTD")
		for (var i = 0; i < allBuyBtns.length; i++) {
			var item = allBuyBtns[i]
			item.addEventListener(getEndClickEvent(), function(event) {
				if ("${user.state}" === "2") {
					showNormalNoticeModal("#div-i-noticeGenDan", "提示：", "试玩账号无法参与合买玩法，请注册为正式会员")
					return
				}
				var self = event.currentTarget.querySelector(".buyBtnSpan")
				//MY_USER_ID
				if ($(event.currentTarget).closest("tr").find(".td-c-hemai-userId").text() === MY_USER_ID) {
					showNormalNoticeModal("#div-i-noticeGenDan", "提示：", "无法购买自己发起的合买")
					return
				}
				HEMAI_OBJECT.id = self.dataset.id
				HEMAI_OBJECT.zcount = self.dataset.zcount
				HEMAI_OBJECT.price = self.dataset.price
				HEMAI_OBJECT.element = self
				var status = self.closest("tr").querySelector(".status-TD").innerHTML
				var sCount = self.closest("tr").querySelector(".scountTD").innerHTML
				HEMAI_OBJECT.orderNum = self.closest("tr").querySelector(".orderNum-TD").innerHTML
				status = status.trim()
				if (status != "认购中") {
					showNormalNoticeModal("#div-i-noticeGenDan", "提示：", status + "状态的订单无法进行购买操作")
					return
				}
				if (sCount == "0") {
					showNormalNoticeModal("#div-i-noticeGenDan", "提示：", "该订单已售空，无法购买")
					return					
				}
				showFakeModal(".div-c-buyContentDiv")
			})
		}			
		document.querySelector("#btn-i-confirmBuyFenShu").addEventListener(getEndClickEvent(), function(event) {
			var buyValue = document.querySelector("#input-buyFenShu").value
		 	if (!checkIsNumber(buyValue)) {
				showNormalNoticeModal("#div-i-noticeGenDan", "提示：", "购买份数填写有误")
				document.querySelector("#input-buyFenShu").value = ""
				return
			}
 			var dataObject = {
				id:HEMAI_OBJECT.id,
				hcount: buyValue,
				rcount: 0,
				bcount: 0,
				zcount:HEMAI_OBJECT.zcount,
				price:HEMAI_OBJECT.price,
				state: 1,
			}
			ajax({
				url:"/zuixinfs.do",
				data:{orderNum: HEMAI_OBJECT.orderNum},
				type:'post',
				success:function(data){
					var json = eval('('+data+')');
					if (json.data == "0") {
						showNormalNoticeModal("#div-i-noticeGenDan", "提示：", "该订单以售空，无法购买")
						document.querySelector(".div-c-buyContentDiv").classList.remove("div-c-buyContentDiv-block")
						return
					}
					else {
						HEMAI_OBJECT.element.closest("tr").querySelector(".scountTD").innerHTML = json.data
					}
					var parentTr = HEMAI_OBJECT.element.closest("tr")
					var shengyuValue = Number(parentTr.querySelector(".scountTD").innerHTML)
					if (Number(buyValue) > shengyuValue) {
						showNormalNoticeModal("#div-i-noticeGenDan", "提示：", "购买份数大于剩余份数")
						document.querySelector("#input-buyFenShu").value = ""
						return							
					}
					var sCount = Number(HEMAI_OBJECT.element.closest("tr").querySelector(".scountTD").innerHTML)
					 ajax({
						url:'/order/submit.do',
						data: dataObject,
						type:'post',
						success:function(data){
							showNormalNoticeModal("#div-i-noticeGenDan", "提示：", "购买成功")
							var json=eval('('+data+')');
							HEMAI_OBJECT.element.closest("tr").querySelector(".scountTD").innerHTML = json.data
							$(".div-c-buyContentDiv .btn-class-closeFakeModal").trigger(getNormalClickEvent())
						},
						error: function(status) {
							showNormalNoticeModal("#div-i-noticeGenDan", "提示：", "网络异常，请稍后重试")
						}
					})
				}
			})	
		})
		stopUserScaleScreenIOS()
		bindAllDetailIndexEvent()
		
		var createHeMaiItem = function(parentDiv ,item, type) {
			$("#parentDiv").html("")
			var wanfaText = ""
			for (var j = 1; j <= 40; j++) {
				var cplayName = item["cplay" + j]
				if (cplayName != undefined) {
					var singleText = item["cplay" + j] + ":" + item["str" + j]
					wanfaText = wanfaText + "<li>" + singleText + "</li>"
				}
			}
			var rengoufenshu = ""
			var baodifenshu = ""
			var canyufenshu = ""
			var typeText = ""
			var shengyuFenShu = ""
			var kaijiangzhuangtaiText = ""
			if (type == "canyu") {
				canyufenshu = "<li>参与份数：<span class='moneyText'>" + item.hcount + " 份</span></li>"
				typeText = "参与"
			} else {
				rengoufenshu = "<li>认购份数：" + item.rcount + " 份</li>"
				baodifenshu	= "<li>保底份数：" + item.bcount + " 份</li>"
				shengyuFenShu = "<li>剩余份数：<span class='moneyText'>" + item.scount + " 份</span></li>"
				typeText = "发起"
			}
			if (item.state == "0" && item.checkNum != null) {
				kaijiangzhuangtaiText = "合买失败"
			} else {
				kaijiangzhuangtaiText = RESULT_STATE_OBJECT[item.state]
			}
			var loetterMoney = ""
				var lotterNumber = ""
				if (item.state == "3") {
					loetterMoney = "<li><i class='fa fa-star'></i> 中奖金额:<span style='color:red;font-weight:bold;'>" + item.zMoney + " 元</span></li>"
				}
				if (item.state != "1") {
					var newLi = "<li><i class='fa fa-star'></i> 开奖号码:</li>"
					lotterNumber = newLi + "<li><span style='color:red;font-weight:bold;word-break:break-all;'>" + item.checkNum + " </span></li>"
				}	
				var html = "<ul class='myHeMaiItem ul-c-gendan-" + type + "'>"+
				"<span style='' class='span-type-hemaiPerson'>我是" + typeText + "者</span>"+
				"<li><span>" + typeText + "者：" + item.user + "</span></li>"+
				"<li><span>方案编号：" + item.orderNum + "</span></li>"+
				"<li>方案金额：<span class='moneyText' style='font-weight:bold;'>" + item.fajine + " 元</span></li>"+
				　　"<li>每份金额：<span class='moneyText' style='font-weight:bold;'>" + item.price + " 元</span></li>"+
				"<li>总份数：" + item.zcount + " 份</li>"+
				rengoufenshu　+ baodifenshu + shengyuFenShu + canyufenshu + 
				"<li>开奖状态:<span style='color:red;font-weight:bold;'> " + kaijiangzhuangtaiText + "</span></li>"+   
				"<li id='li-i-btnDetail'><button class='btn btn-success btn-showDetailHeMaiItem'>显示详情</button></li>"+
				"<ul class='sub-ul-wanfa'>"+
				"<li><i class='fa fa-star'></i> 彩种:" + item.cname1 + "</li>"+
				"<li><i class='fa fa-star'></i> 期号:" + item.qihao + "</li>"+
				"<li><i class='fa fa-star'></i> 创建时间:" + item.createTime + "</li>"+
				loetterMoney + 
				lotterNumber + 
				"<li><i class='fa fa-star'></i> 投注号码</li>" + wanfaText + 
				"</ul>"
			"</ul>"
			$(parentDiv).append(html)			
		}
		
		
		var insertGenDanItem = function(data, $node, type) {
			var newData = JSON.parse(data)
			$($node).html("")
			var $titleSpan = $($node).prev().find(".span-c-tiaoshu")
			for (var i = 0; i < newData.data.length; i++) {
				var dataItem = newData.data[i]
				if (!dataItem) {continue}
				createHeMaiItem($node, dataItem, type)
			}
			if ($($node + " .myHeMaiItem").length == 0) {
				if (type == "canyu") {
					type = "参与"
				}
				else {
					type = "发起"
				}
				$($node).append("暂无" + type + "的合买")
			}		
			$titleSpan.text($($node)[0].children.length)
		}
				
		document.querySelector("#span-i-myHeMai").addEventListener(getEndClickEvent(), function(event) {
 			var urlPath = "/ohm.do"
				var newRequest = {
				url: urlPath,
				type: "post",
				data: {},
				success: function(data) {
					var newData = JSON.parse(data)
					insertGenDanItem(data, "#div-i-MyFaQiHeMai", "faqi")
					var urlPath = "/ohm1.do"
					var newRequest = {
						url: urlPath,
						type: "post",
						data: {},
						success: function(data) {
							var newData = JSON.parse(data)
							insertGenDanItem(data, "#div-i-MyCanYuHeMai", "canyu")
							document.body.classList.add("cancelScroll")
							$("#myModal").modal("show")						
	 					},
						error: function(status) {
							showNormalNoticeModal("#div-i-noticeGenDan", "提示：", "网络异常，请稍后重试")
						}
					}
					ajax(newRequest)					
				},
				error: function(status) {
					showNormalNoticeModal("#div-i-noticeGenDan", "提示：", "网络异常，请稍后重试")
				}
			}	
			ajax(newRequest)
		})
		$("#div-i-myHeMaiBody").on(getEndClickEvent(), ".btn-showDetailHeMaiItem", function(event) {
			$(event.target).closest(".myHeMaiItem").toggleClass("active")
		})
		$('#myModal').on('hidden.bs.modal', function () {
			document.body.classList.remove("cancelScroll")
		})			
		$('#detail-modal').on('hidden.bs.modal', function () {
			document.body.classList.remove("cancelScroll")
		})			
		bindCollapseItemEvent()
	</script>
</html>